# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=emacs-compat
pkgver=30.0.0.0
pkgrel=0
_pkgreal=compat
pkgdesc="Forwards-compatibility library for Emacs Lisp"
url="https://github.com/emacs-compat/compat"
arch="noarch"
license="GPL-3.0-or-later"
depends="cmd:emacs"
makedepends="emacs-nox"
source="https://github.com/emacs-compat/compat/archive/$pkgver/emacs-compat-$pkgver.tar.gz"
builddir="$srcdir/$_pkgreal-$pkgver"

prepare() {
	default_prepare

	# $pkgver in directory name is needed for
	# compat-package-get-version test to pass
	mkdir -v test-$pkgver
	mv -v compat-tests.el test-$pkgver/
}

build() {
	emacs -batch -q -no-site-file -L . \
		-eval '(setq compat-strict t byte-compile-error-on-warn t)' \
		-f batch-byte-compile \
		./*.el
}

check() {
	emacs -batch -q -no-site-file -L . -L test-$pkgver \
		-l compat-tests -f ert-run-tests-batch-and-exit
}

package() {
	install -Dvm644 ./*.el ./*.elc \
		-t "$pkgdir"/usr/share/emacs/site-lisp/$_pkgreal/

	cd "$pkgdir"/usr/share/emacs/site-lisp/$_pkgreal
	emacs -batch -q -no-site-file \
		-eval "(loaddefs-generate \".\" \"$_pkgreal-loaddefs.el\")"
}

sha512sums="
04e2c26f6c1fbb78fc0f2de70913694b3f37614a6992b2a36cec5288c2083481701bdfb7d7e981582c8b22cf61b71e5a3e6011f86c1602331a26ad61c1fe2f66  emacs-compat-30.0.0.0.tar.gz
"
